
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>设备管理 · book for xbook2</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="jason hu">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="ahci.html" />
    
    
    <link rel="prev" href="../mm/mm.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://book-os.org" target="_blank" class="custom-link">bookos</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" >
            
                <span>
            
                    
                    xbook2文档中心
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" >
            
                <span>
            
                    
                    简介
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    xbook2 简介
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.1.2" >
            
                <span>
            
                    
                    快速上手
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.2.1" data-path="../../tutorial/quick-start.html">
            
                <a href="../../tutorial/quick-start.html">
            
                    
                    Qemu x86
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.1.3" >
            
                <span>
            
                    
                    内核
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1" data-path="../base/base.html">
            
                <a href="../base/base.html">
            
                    
                    内核基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3.2" data-path="../task/task.html">
            
                <a href="../task/task.html">
            
                    
                    任务管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3.3" data-path="../timer/timer.html">
            
                <a href="../timer/timer.html">
            
                    
                    时钟管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3.4" data-path="../mm/mm.html">
            
                <a href="../mm/mm.html">
            
                    
                    内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.1.3.5" data-path="device.html">
            
                <a href="device.html">
            
                    
                    设备管理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.5.1" data-path="ahci.html">
            
                <a href="ahci.html">
            
                    
                    AHCI磁盘驱动分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3.5.2" data-path="keyboard.html">
            
                <a href="keyboard.html">
            
                    
                    PS/2键盘驱动分析
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.1.4" >
            
                <span>
            
                    
                    用户
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.4.1" data-path="../user/user.html">
            
                <a href="../user/user.html">
            
                    
                    用户编程
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.1.5" >
            
                <span>
            
                    
                    other
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.5.1" data-path="../../other/FAQS.html">
            
                <a href="../../other/FAQS.html">
            
                    
                    FAQS
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >设备管理</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="io&#x8BBE;&#x5907;&#x7BA1;&#x7406;">I/O&#x8BBE;&#x5907;&#x7BA1;&#x7406;</h1>
<p>&#x7B80;&#x5355;&#x6765;&#x8BF4;&#x5C31;&#x662F;&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x5F00;&#x53D1;&#xFF0C;xbook2&#x7684;&#x9A71;&#x52A8;&#x6846;&#x67B6;&#x6765;&#x6E90;&#x4E8E;windowsNT&#x5185;&#x6838;&#xFF0C;&#x5B83;&#x662F;&#x4EE5;driver object&#x4E3A;&#x4E00;&#x4E2A;&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#xFF0C;&#x4EE5;device object&#x4E3A;&#x4E00;&#x4E2A;&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x4E0A;&#x7684;&#x8BBE;&#x5907;&#x3002;&#x5178;&#x578B;&#x7684;&#x6848;&#x4F8B;&#x5C31;&#x662F;&#xFF0C;&#x4E00;&#x4E2A;tty&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#xFF0C;&#x5BF9;&#x5E94;&#x7740;&#x591A;&#x4E2A;tty&#x8BBE;&#x5907;&#xFF0C;tty0&#xFF0C;tty1&#xFF0C;tty2...tty7&#x3002;&#x672C;&#x7AE0;&#x5C06;&#x8BB2;&#x89E3;&#x5982;&#x4F55;&#x5728;xbook2&#x4E2D;&#x5F00;&#x53D1;&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#xFF0C;&#x8FD9;&#x5E94;&#x8BE5;&#x662F;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x5185;&#x6838;&#x4E2D;&#x6BD4;&#x8F83;&#x5F00;&#x653E;&#x7684;&#x4E00;&#x4E2A;&#x6A21;&#x5757;&#x4E86;&#x3002;</p>
<h2 id="&#x9A71;&#x52A8;&#x6846;&#x67B6;">&#x9A71;&#x52A8;&#x6846;&#x67B6;</h2>
<h3 id="&#x4E00;&#x3001;&#x91CD;&#x8981;&#x7ED3;&#x6784;&#x4F53;&#x4ECB;&#x7ECD;">&#x4E00;&#x3001;&#x91CD;&#x8981;&#x7ED3;&#x6784;&#x4F53;&#x4ECB;&#x7ECD;</h3>
<p>&#x5728;xbook2&#x79CD;&#xFF0C;&#x6BCF;&#x4E2A;&#x9A71;&#x52A8;&#x90FD;&#x9700;&#x8981;&#x6709;&#x4E00;&#x4E2A;&#x9A71;&#x52A8;&#x5BF9;&#x8C61;&#xFF0C;&#x6765;&#x5B58;&#x653E;&#x8FD9;&#x4E2A;&#x9A71;&#x52A8;&#x7684;&#x76F8;&#x5173;&#x4FE1;&#x606F;&#xFF0C;&#x5982;&#x9A71;&#x52A8;&#x7684;&#x5165;&#x53E3;&#xFF0C;&#x529F;&#x80FD;&#x51FD;&#x6570;&#x7B49;&#x3002;</p>
<pre><code class="lang-c"><span class="hljs-comment">/* &#x9A71;&#x52A8;&#x5BF9;&#x8C61; */</span>
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">struct</span> _driver_object
{
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> flags;                 <span class="hljs-comment">/* &#x9A71;&#x52A8;&#x6807;&#x5FD7; */</span>
    <span class="hljs-keyword">list_t</span> <span class="hljs-built_in">list</span>;                        <span class="hljs-comment">/* &#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x6784;&#x6210;&#x4E00;&#x4E2A;&#x94FE;&#x8868; */</span>
    <span class="hljs-keyword">list_t</span> device_list;                 <span class="hljs-comment">/* &#x9A71;&#x52A8;&#x4E0B;&#x7684;&#x8BBE;&#x5907;&#x6784;&#x6210;&#x7684;&#x94FE;&#x8868; */</span>
    <span class="hljs-keyword">struct</span> drver_extension *drver_extension; <span class="hljs-comment">/* &#x9A71;&#x52A8;&#x6269;&#x5C55; */</span>
    <span class="hljs-keyword">string_t</span> name;                      <span class="hljs-comment">/* &#x540D;&#x5B57; */</span>
    <span class="hljs-comment">/* &#x9A71;&#x52A8;&#x63A7;&#x5236;&#x51FD;&#x6570; */</span>
    <span class="hljs-keyword">driver_func_t</span> driver_enter;
    <span class="hljs-keyword">driver_func_t</span> driver_exit;

    <span class="hljs-comment">/* &#x9A71;&#x52A8;&#x6D3E;&#x9063;&#x51FD;&#x6570; */</span>  
    <span class="hljs-keyword">driver_dispatch_t</span> dispatch_function[MAX_IOREQ_FUNCTION_NR];
    <span class="hljs-keyword">spinlock_t</span> device_lock;             <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x9501; */</span>
} <span class="hljs-keyword">driver_object_t</span>;
</code></pre>
<p><code>device_list</code>&#x8BB0;&#x5F55;&#x8005;&#x8FD9;&#x4E2A;&#x9A71;&#x52A8;&#x5BF9;&#x5E94;&#x7684;&#x6240;&#x6709;&#x8BBE;&#x5907;&#x5BF9;&#x8C61;&#xFF0C;&#x8BBE;&#x5907;&#x5BF9;&#x8C61;&#x63CF;&#x8FF0;&#x4E86;&#x6BCF;&#x4E00;&#x4E2A;&#x5177;&#x4F53;&#x7684;&#x8BBE;&#x5907;&#x3002;</p>
<pre><code class="lang-c"><span class="hljs-comment">/* &#x8BBE;&#x5907;&#x5BF9;&#x8C61; */</span>
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">struct</span> _device_object
{
    <span class="hljs-keyword">list_t</span> <span class="hljs-built_in">list</span>;                        <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x5728;&#x9A71;&#x52A8;&#x4E2D;&#x7684;&#x94FE;&#x8868; */</span>
    <span class="hljs-keyword">device_type_t</span> type;                 <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x7C7B;&#x578B; */</span>
    <span class="hljs-keyword">struct</span> _driver_object *driver;      <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x6240;&#x5728;&#x7684;&#x9A71;&#x52A8; */</span>
    <span class="hljs-keyword">void</span> *device_extension;             <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x6269;&#x5C55;&#xFF0C;&#x81EA;&#x5B9A;&#x4E49; */</span>
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> flags;                 <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x6807;&#x5FD7; */</span>
    <span class="hljs-keyword">atomic_t</span> reference;                 <span class="hljs-comment">/* &#x5F15;&#x7528;&#x8BA1;&#x6570;&#xFF0C;&#x7BA1;&#x7406;&#x8BBE;&#x5907;&#x6253;&#x5F00;&#x60C5;&#x51B5; */</span>
    <span class="hljs-keyword">io_request_t</span> *cur_ioreq;            <span class="hljs-comment">/* &#x5F53;&#x524D;&#x6B63;&#x5728;&#x5904;&#x7406;&#x7684;io&#x8BF7;&#x6C42; */</span>
    <span class="hljs-keyword">string_t</span> name;                      <span class="hljs-comment">/* &#x540D;&#x5B57; */</span>
    <span class="hljs-keyword">uint16_t</span> mtime;                     <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x4FEE;&#x6539;&#x65F6;&#x7684;&#x65F6;&#x95F4; */</span>
    <span class="hljs-keyword">uint16_t</span> mdate;                     <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x4FEE;&#x6539;&#x65F6;&#x7684;&#x65E5;&#x671F; */</span>
    <span class="hljs-keyword">struct</span> {
        <span class="hljs-keyword">spinlock_t</span> spinlock;            <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x81EA;&#x65CB;&#x9501; */</span>
        <span class="hljs-keyword">mutexlock_t</span> mutexlock;          <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x4E92;&#x65A5;&#x9501; */</span>
    } lock;
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> reserved;             <span class="hljs-comment">/* &#x9884;&#x7559; */</span>
} <span class="hljs-keyword">device_object_t</span>;
</code></pre>
<p><code>type</code>&#x8BB0;&#x5F55;&#x4E86;&#x8BBE;&#x5907;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x76EE;&#x524D;&#x7684;&#x8BBE;&#x5907;&#x7C7B;&#x578B;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-c"><span class="hljs-keyword">typedef</span> <span class="hljs-keyword">enum</span> _device_type {
    DEVICE_TYPE_ANY,                    <span class="hljs-comment">/* &#x4EFB;&#x610F;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_BEEP,                   <span class="hljs-comment">/* &#x8702;&#x9E23;&#x5668;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_DISK,                   <span class="hljs-comment">/* &#x78C1;&#x76D8;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_KEYBOARD,               <span class="hljs-comment">/* &#x952E;&#x76D8;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_MOUSE,                  <span class="hljs-comment">/* &#x9F20;&#x6807;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_NULL,                   <span class="hljs-comment">/* &#x7A7A;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_PORT,                   <span class="hljs-comment">/* &#x7AEF;&#x53E3;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_SERIAL_PORT,            <span class="hljs-comment">/* &#x4E32;&#x53E3;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_PARALLEL_PORT,           <span class="hljs-comment">/* &#x5E76;&#x53E3;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_PHYSIC_NETCARD,          <span class="hljs-comment">/* &#x7269;&#x7406;&#x7F51;&#x5361;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_PRINTER,                 <span class="hljs-comment">/* &#x6253;&#x5370;&#x673A;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_SCANNER,                 <span class="hljs-comment">/* &#x626B;&#x63CF;&#x4EEA;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_SCREEN,                  <span class="hljs-comment">/* &#x5C4F;&#x5E55;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_SOUND,                   <span class="hljs-comment">/* &#x58F0;&#x97F3;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_STREAM,                  <span class="hljs-comment">/* &#x6D41;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_UNKNOWN,                 <span class="hljs-comment">/* &#x672A;&#x77E5;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_VIDEO,                   <span class="hljs-comment">/* &#x89C6;&#x9891;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_VIRTUAL_DISK,            <span class="hljs-comment">/* &#x865A;&#x62DF;&#x78C1;&#x76D8;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_VIRTUAL_CHAR,            <span class="hljs-comment">/* &#x865A;&#x62DF;&#x5B57;&#x7B26;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_WAVE_IN,                 <span class="hljs-comment">/* &#x58F0;&#x97F3;&#x8F93;&#x5165;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_WAVE_OUT,                <span class="hljs-comment">/* &#x58F0;&#x97F3;&#x8F93;&#x51FA;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_8042_PORT,               <span class="hljs-comment">/* 8042&#x7AEF;&#x53E3;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_NETWORK,                 <span class="hljs-comment">/* &#x7F51;&#x7EDC;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_BUS_EXTERNDER,           <span class="hljs-comment">/* BUS&#x603B;&#x7EBF;&#x6269;&#x5C55;&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_ACPI,                    <span class="hljs-comment">/* ACPI&#x8BBE;&#x5907; */</span>
    DEVICE_TYPE_VIEW,                   <span class="hljs-comment">/* &#x89C6;&#x56FE;&#x8BBE;&#x5907; */</span>
    MAX_DEVICE_TYPE_NR
} <span class="hljs-keyword">device_type_t</span>;
</code></pre>
<p>&#x5F53;&#x6211;&#x4EEC;&#x5F00;&#x53D1;&#x9A71;&#x52A8;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x4E3A;&#x521B;&#x5EFA;&#x7684;&#x8BBE;&#x5907;&#x6307;&#x5B9A;&#x4E00;&#x4E2A;&#x8BBE;&#x5907;&#x7C7B;&#x578B;&#x3002;&#x4E0A;&#x5C42;&#x5E94;&#x7528;&#x9700;&#x8981;&#x6839;&#x636E;&#x8BBE;&#x5907;&#x7C7B;&#x578B;&#x6765;&#x67E5;&#x627E;&#x67D0;&#x79CD;&#x7C7B;&#x578B;&#x8BBE;&#x5907;&#x7684;&#x4F7F;&#x7528;&#x60C5;&#x51B5;&#x3002;</p>
<p>&#x8FD8;&#x6709;&#x4E00;&#x4E2A;&#x91CD;&#x8981;&#x7684;&#x6210;&#x5458;<code>device_extension</code>&#xFF0C;&#x8FD9;&#x4E2A;&#x662F;&#x6BCF;&#x4E2A;&#x8BBE;&#x5907;&#x7684;&#x6269;&#x5C55;&#x6307;&#x9488;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x6BCF;&#x4E2A;&#x8BBE;&#x5907;&#x90FD;&#x53EF;&#x4EE5;&#x6307;&#x5411;&#x4E00;&#x4E2A;&#x79C1;&#x6709;&#x7ED3;&#x6784;&#x4F53;&#xFF0C;&#x7528;&#x8BE5;&#x7ED3;&#x6784;&#x4F53;&#x5B58;&#x653E;&#x6570;&#x636E;&#xFF0C;&#x8FD9;&#x4E2A;&#x5728;&#x540E;&#x9762;&#x9A71;&#x52A8;&#x5F00;&#x53D1;&#x65F6;&#x975E;&#x5E38;&#x6709;&#x7528;&#x3002;</p>
<h3 id="&#x4E8C;&#x3001;&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x7ED3;&#x6784;">&#x4E8C;&#x3001;&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x7ED3;&#x6784;</h3>
<p>&#x8FD9;&#x91CC;&#xFF0C;&#x7ED9;&#x51FA;&#x4E00;&#x4E2A;&#x6700;&#x57FA;&#x7840;&#x7684;&#x7A0B;&#x5E8F;&#x7ED3;&#x6784;&#xFF1A;</p>
<pre><code class="lang-c"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;xbook/bitops.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;xbook/driver.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;xbook/debug.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;xbook/task.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;string.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdio.h&gt;</span></span>

<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> DRV_NAME <span class="hljs-string">&quot;xxx&quot;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> DRV_VERSION <span class="hljs-string">&quot;0.1&quot;</span></span>

<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> DEV_NAME <span class="hljs-string">&quot;xxx&quot;</span></span>

<span class="hljs-comment">// #define DEBUG_DRV</span>

<span class="hljs-function"><span class="hljs-keyword">static</span> iostatus_t <span class="hljs-title">xxx_enter</span><span class="hljs-params">(driver_object_t *driver)</span>
</span>{
    <span class="hljs-keyword">iostatus_t</span> status;

    <span class="hljs-keyword">device_object_t</span> *devobj;
    <span class="hljs-comment">/* &#x521B;&#x5EFA;&#x8BBE;&#x5907; */</span>
    status = io_create_device(driver, <span class="hljs-number">0</span>, DEV_NAME, DEVICE_TYPE_XXX, &amp;devobj);
    <span class="hljs-keyword">if</span> (status != IO_SUCCESS) {
        keprint(PRINT_ERR <span class="hljs-string">&quot;zero_enter: create device failed!\n&quot;</span>);
        <span class="hljs-keyword">return</span> status;
    }
    <span class="hljs-keyword">return</span> status;
}

<span class="hljs-function"><span class="hljs-keyword">static</span> iostatus_t <span class="hljs-title">xxx_exit</span><span class="hljs-params">(driver_object_t *driver)</span>
</span>{
    <span class="hljs-comment">/* &#x904D;&#x5386;&#x6240;&#x6709;&#x5BF9;&#x8C61; */</span>
    <span class="hljs-keyword">device_object_t</span> *devobj, *next;
    <span class="hljs-comment">/* &#x7531;&#x4E8E;&#x6D89;&#x53CA;&#x5230;&#x8981;&#x91CA;&#x653E;devobj&#xFF0C;&#x6240;&#x4EE5;&#x9700;&#x8981;&#x4F7F;&#x7528;safe&#x7248;&#x672C; */</span>
    list_for_each_owner_safe (devobj, next, &amp;driver-&gt;device_list, <span class="hljs-built_in">list</span>) {
        io_delete_device(devobj);   <span class="hljs-comment">/* &#x5220;&#x9664;&#x6BCF;&#x4E00;&#x4E2A;&#x8BBE;&#x5907; */</span>
    }
    string_del(&amp;driver-&gt;name); <span class="hljs-comment">/* &#x5220;&#x9664;&#x9A71;&#x52A8;&#x540D; */</span>
    <span class="hljs-keyword">return</span> IO_SUCCESS;
}

<span class="hljs-keyword">iostatus_t</span> xxx_driver_func(<span class="hljs-keyword">driver_object_t</span> *driver)
{
    <span class="hljs-keyword">iostatus_t</span> status = IO_SUCCESS;

    <span class="hljs-comment">/* &#x7ED1;&#x5B9A;&#x9A71;&#x52A8;&#x4FE1;&#x606F; */</span>
    driver-&gt;driver_enter = xxx_enter;
    driver-&gt;driver_exit = xxx_exit;

    driver-&gt;dispatch_function[IOREQ_READ] = xxx_read;

    <span class="hljs-comment">/* &#x521D;&#x59CB;&#x5316;&#x9A71;&#x52A8;&#x540D;&#x5B57; */</span>
    string_new(&amp;driver-&gt;name, DRV_NAME, DRIVER_NAME_LEN);
<span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> DEBUG_DRV</span>
    keprint(PRINT_DEBUG <span class="hljs-string">&quot;zero_driver_func: driver name=%s\n&quot;</span>,
        driver-&gt;name.text);
<span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span>

    <span class="hljs-keyword">return</span> status;
}

<span class="hljs-keyword">static</span> __<span class="hljs-function">init <span class="hljs-keyword">void</span> <span class="hljs-title">xxx_driver_entry</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span>
</span>{
    <span class="hljs-keyword">if</span> (driver_object_create(xxx_driver_func) &lt; <span class="hljs-number">0</span>) {
        keprint(PRINT_ERR <span class="hljs-string">&quot;[driver]: %s create driver failed!\n&quot;</span>, __func__);
    }
}

driver_initcall(xxx_driver_entry);
</code></pre>
<h2 id="&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x5206;&#x6790;">&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x5206;&#x6790;</h2>
<h3 id="null&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x5206;&#x6790;">null&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x5206;&#x6790;</h3>
<p>&#x8FD9;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x4EE5;null&#x9A71;&#x52A8;&#x4E3A;&#x4F8B;&#xFF0C;&#x8BB2;&#x89E3;xbook2&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x7684;&#x7ED3;&#x6784;&#xFF0C;&#x8FD9;&#x6837;&#x4F7F;&#x5F00;&#x53D1;&#x8005;&#x5728;&#x5F00;&#x53D1;&#x81EA;&#x5DF1;&#x7684;&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x65F6;&#x53D8;&#x5F97;&#x8F7B;&#x677E;&#x3002;</p>
<p><code>xbook2/src/drivers/char/zero.c</code></p>
<pre><code class="lang-c"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;xbook/debug.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;xbook/bitops.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;string.h&gt;</span></span>

<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;xbook/driver.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;xbook/task.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;xbook/virmem.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;arch/io.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;arch/interrupt.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;sys/ioctl.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdio.h&gt;</span></span>

<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> DRV_NAME <span class="hljs-string">&quot;virt-zero&quot;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> DRV_VERSION <span class="hljs-string">&quot;0.1&quot;</span></span>

<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> DEV_NAME <span class="hljs-string">&quot;zero&quot;</span></span>

<span class="hljs-comment">// #define DEBUG_DRV</span>

<span class="hljs-keyword">iostatus_t</span> zero_read(<span class="hljs-keyword">device_object_t</span> *device, <span class="hljs-keyword">io_request_t</span> *ioreq)
{
    <span class="hljs-keyword">iostatus_t</span> status = IO_SUCCESS;
<span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> DEBUG_DRV</span>
    keprint(PRINT_DEBUG <span class="hljs-string">&quot;zero_read: data:\n&quot;</span>);
<span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span>
    <span class="hljs-keyword">int</span> len = ioreq-&gt;parame.read.length;
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> *data = (<span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> *) ioreq-&gt;user_buffer;
    <span class="hljs-keyword">while</span> (len-- &gt; <span class="hljs-number">0</span>) {
        *data = <span class="hljs-number">0</span>;
        data++;
    }

    ioreq-&gt;io_status.infomation = ioreq-&gt;parame.read.length;    <span class="hljs-comment">/* &#x8BFB;&#x53D6;&#x6C38;&#x8FDC;&#x662F;0 */</span>
    ioreq-&gt;io_status.status = status;
    io_complete_request(ioreq);
    <span class="hljs-keyword">return</span> status;
}

<span class="hljs-function"><span class="hljs-keyword">static</span> iostatus_t <span class="hljs-title">zero_enter</span><span class="hljs-params">(driver_object_t *driver)</span>
</span>{
    <span class="hljs-keyword">iostatus_t</span> status;

    <span class="hljs-keyword">device_object_t</span> *devobj;
    <span class="hljs-comment">/* &#x521D;&#x59CB;&#x5316;&#x4E00;&#x4E9B;&#x5176;&#x5B83;&#x5185;&#x5BB9; */</span>
    status = io_create_device(driver, <span class="hljs-number">0</span>, DEV_NAME, DEVICE_TYPE_VIRTUAL_CHAR, &amp;devobj);
    <span class="hljs-keyword">if</span> (status != IO_SUCCESS) {
        keprint(PRINT_ERR <span class="hljs-string">&quot;zero_enter: create device failed!\n&quot;</span>);
        <span class="hljs-keyword">return</span> status;
    }
    <span class="hljs-comment">/* neighter io mode */</span>
    devobj-&gt;flags = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">return</span> status;
}

<span class="hljs-function"><span class="hljs-keyword">static</span> iostatus_t <span class="hljs-title">zero_exit</span><span class="hljs-params">(driver_object_t *driver)</span>
</span>{
    <span class="hljs-comment">/* &#x904D;&#x5386;&#x6240;&#x6709;&#x5BF9;&#x8C61; */</span>
    <span class="hljs-keyword">device_object_t</span> *devobj, *next;
    <span class="hljs-comment">/* &#x7531;&#x4E8E;&#x6D89;&#x53CA;&#x5230;&#x8981;&#x91CA;&#x653E;devobj&#xFF0C;&#x6240;&#x4EE5;&#x9700;&#x8981;&#x4F7F;&#x7528;safe&#x7248;&#x672C; */</span>
    list_for_each_owner_safe (devobj, next, &amp;driver-&gt;device_list, <span class="hljs-built_in">list</span>) {
        io_delete_device(devobj);   <span class="hljs-comment">/* &#x5220;&#x9664;&#x6BCF;&#x4E00;&#x4E2A;&#x8BBE;&#x5907; */</span>
    }
    string_del(&amp;driver-&gt;name); <span class="hljs-comment">/* &#x5220;&#x9664;&#x9A71;&#x52A8;&#x540D; */</span>
    <span class="hljs-keyword">return</span> IO_SUCCESS;
}

<span class="hljs-keyword">iostatus_t</span> zero_driver_func(<span class="hljs-keyword">driver_object_t</span> *driver)
{
    <span class="hljs-keyword">iostatus_t</span> status = IO_SUCCESS;

    <span class="hljs-comment">/* &#x7ED1;&#x5B9A;&#x9A71;&#x52A8;&#x4FE1;&#x606F; */</span>
    driver-&gt;driver_enter = zero_enter;
    driver-&gt;driver_exit = zero_exit;

    driver-&gt;dispatch_function[IOREQ_READ] = zero_read;

    <span class="hljs-comment">/* &#x521D;&#x59CB;&#x5316;&#x9A71;&#x52A8;&#x540D;&#x5B57; */</span>
    string_new(&amp;driver-&gt;name, DRV_NAME, DRIVER_NAME_LEN);
<span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> DEBUG_DRV</span>
    keprint(PRINT_DEBUG <span class="hljs-string">&quot;zero_driver_func: driver name=%s\n&quot;</span>,
        driver-&gt;name.text);
<span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span>

    <span class="hljs-keyword">return</span> status;
}

<span class="hljs-keyword">static</span> __<span class="hljs-function">init <span class="hljs-keyword">void</span> <span class="hljs-title">zero_driver_entry</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span>
</span>{
    <span class="hljs-keyword">if</span> (driver_object_create(zero_driver_func) &lt; <span class="hljs-number">0</span>) {
        keprint(PRINT_ERR <span class="hljs-string">&quot;[driver]: %s create driver failed!\n&quot;</span>, __func__);
    }
}

driver_initcall(zero_driver_entry);
</code></pre>
<p>&#x6211;&#x4EEC;&#x4ECE;&#x5E95;&#x90E8;&#x7F51;&#x4E0A;&#x5206;&#x6790;&#xFF0C;&#x6700;&#x5F00;&#x59CB;&#x6709;&#x4E00;&#x4E2A;<code>driver_initcall</code>&#xFF0C;&#x53C2;&#x6570;&#x662F;<code>zero_driver_entry</code>&#xFF0C;&#x8868;&#x793A;&#x5728;&#x521D;&#x59CB;&#x5316;&#x9A71;&#x52A8;&#x7684;&#x65F6;&#x5019;&#x6765;&#x8C03;&#x7528;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#xFF0C;&#x90A3;&#x4E48;&#x8FD9;&#x4E2A;&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x5C31;&#x4F1A;&#x88AB;&#x521D;&#x59CB;&#x5316;&#x4E86;&#x3002;</p>
<p>&#x5728;<code>zero_driver_entry</code>&#x91CC;&#x9762;&#xFF0C;&#x8C03;&#x7528;&#x4E86;<code>driver_object_create</code>&#x51FD;&#x6570;&#x6765;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x9A71;&#x52A8;&#x5BF9;&#x8C61;&#xFF0C;&#x4F20;&#x5165;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x8868;&#x793A;&#x8FD9;&#x4E2A;&#x9A71;&#x52A8;&#x5BF9;&#x8C61;&#x521D;&#x59CB;&#x5316;&#x7684;&#x65F6;&#x5019;&#x4F1A;&#x53BB;&#x8C03;&#x7528;&#x7684;&#x51FD;&#x6570;&#x3002;</p>
<p>&#x5728;&#x90A3;&#x4E2A;&#x51FD;&#x6570;&#x79CD;&#xFF0C;&#x9700;&#x8981;&#x586B;&#x5199;&#x8FD9;&#x4E2A;&#x9A71;&#x52A8;&#x5BF9;&#x8C61;&#x7684;&#x4E00;&#x4E9B;&#x4FE1;&#x606F;&#xFF0C;&#x6BD4;&#x5982;&#x9A71;&#x52A8;&#x7684;&#x8FDB;&#x5165;<code>driver_enter</code>&#x548C;&#x9000;&#x51FA;<code>driver_exit</code>&#xFF0C;&#x8868;&#x793A;&#x5F00;&#x59CB;&#x6267;&#x884C;&#x548C;&#x9000;&#x51FA;&#x6267;&#x884C;&#x65F6;&#x8C03;&#x7528;&#x7684;&#x51FD;&#x6570;&#x3002;&#x5F00;&#x59CB;&#x6267;&#x884C;&#x51FD;&#x6570;<code>zero_enter</code> &#xFF0C;&#x5F53;&#x7CFB;&#x7EDF;&#x91CD;&#x542F;&#x6216;&#x8005;&#x5173;&#x95ED;&#x65F6;&#xFF0C;&#x5C31;&#x4F1A;&#x8C03;&#x7528;&#x9000;&#x51FA;&#x51FD;&#x6570;<code>zero_exit</code>&#x3002;</p>
<p><code>dispatch_function</code>&#x6D3E;&#x9063;&#x51FD;&#x6570;&#x7684;&#x610F;&#x601D;&#x5C31;&#x662F;&#x5F53;&#x9A71;&#x52A8;&#x9700;&#x8981;&#x6267;&#x884C;&#x67D0;&#x4E2A;&#x529F;&#x80FD;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5C31;&#x4F1A;&#x8C03;&#x7528;&#x5BF9;&#x5E94;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x5728;null&#x9A71;&#x52A8;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x8BBE;&#x7F6E;&#x4E86;<code>IOREQ_READ</code>&#x64CD;&#x4F5C;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BFB;&#x64CD;&#x4F5C;&#xFF0C;&#x8FD9;&#x91CC;&#x7ED1;&#x5B9A;&#x4E86;<code>zero_read</code>&#xFF0C;&#x90A3;&#x4E48;&#x5F53;&#x9A71;&#x52A8;&#x53D1;&#x751F;&#x8BFB;&#x53D6;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5C31;&#x4F1A;&#x53BB;&#x8C03;&#x7528;<code>zero_read</code>&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x8FDB;&#x884C;&#x6570;&#x636E;&#x8BFB;&#x53D6;&#x3002;</p>
<p>&#x6D3E;&#x9063;&#x51FD;&#x6570;&#x652F;&#x6301;&#xFF1A;</p>
<pre><code class="lang-c"><span class="hljs-comment">/* io&#x8BF7;&#x6C42;&#x51FD;&#x6570;&#x8868; */</span>
<span class="hljs-keyword">enum</span> _io_request_function {
    IOREQ_OPEN,                     <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x6253;&#x5F00;&#x6D3E;&#x9063;&#x7D22;&#x5F15; */</span>
    IOREQ_CLOSE,                    <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x5173;&#x95ED;&#x6D3E;&#x9063;&#x7D22;&#x5F15; */</span>        
    IOREQ_READ,                     <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x8BFB;&#x53D6;&#x6D3E;&#x9063;&#x7D22;&#x5F15; */</span>
    IOREQ_WRITE,                    <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x5199;&#x5165;&#x6D3E;&#x9063;&#x7D22;&#x5F15; */</span>
    IOREQ_DEVCTL,                   <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x63A7;&#x5236;&#x6D3E;&#x9063;&#x7D22;&#x5F15; */</span>
    IOREQ_MMAP,                     <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x5185;&#x5B58;&#x6620;&#x5C04;&#x6D3E;&#x9063;&#x7D22;&#x5F15; */</span>
    IOREQ_FASTIO,                   <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x5FEB;&#x901F;IO&#x6D3E;&#x9063;&#x7D22;&#x5F15; */</span>
    IOREQ_FASTREAD,                 <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x5FEB;&#x901F;&#x8BFB;&#x53D6;&#x6D3E;&#x9063;&#x7D22;&#x5F15; */</span>
    IOREQ_FASTWRITE,                <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x5FEB;&#x901F;&#x5199;&#x5165;&#x6D3E;&#x9063;&#x7D22;&#x5F15; */</span>
    MAX_IOREQ_FUNCTION_NR
};
</code></pre>
<p>&#x5982;&#x679C;&#x9700;&#x8981;&#x652F;&#x6301;&#x67D0;&#x4E2A;&#x64CD;&#x4F5C;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x7ED1;&#x5B9A;&#x5BF9;&#x5E94;&#x7684;&#x6D3E;&#x9063;&#x51FD;&#x6570;&#x5373;&#x53EF;&#xFF0C;&#x8FD9;&#x4E2A;&#x53EF;&#x4EE5;&#x5728;&#x5176;&#x5B83;&#x9A71;&#x52A8;&#x4E2D;&#x4F53;&#x73B0;&#x3002;</p>
<p>&#x6700;&#x540E;&#x901A;&#x8FC7;<code>string_new</code>&#x4E3A;&#x9A71;&#x52A8;&#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A;&#x9A71;&#x52A8;&#x540D;&#x5B57;&#xFF0C;&#x4E00;&#x822C;&#x6211;&#x4EEC;&#x90FD;&#x901A;&#x8FC7;<code>DRV_NAME</code>&#x5B8F;&#x6765;&#x6307;&#x5B9A;&#x9A71;&#x52A8;&#x7684;&#x540D;&#x5B57;&#x3002;</p>
<p><code>zero_enter</code>&#x51FD;&#x6570;&#x4E2D;&#x662F;&#x771F;&#x6B63;&#x8FDB;&#x53BB;&#x9A71;&#x52A8;&#x521D;&#x59CB;&#x5316;&#x65F6;&#x6267;&#x884C;&#x7684;&#x5185;&#x5BB9;&#xFF0C;&#x5728;&#x8FD9;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x901A;&#x8FC7;<code>io_create_device</code>&#x521B;&#x5EFA;&#x8BBE;&#x5907;&#x5BF9;&#x8C61;&#xFF0C;&#x5E76;&#x4E14;&#x5BF9;&#x8BBE;&#x5907;&#x5BF9;&#x8C61;&#x8FDB;&#x884C;&#x521D;&#x59CB;&#x5316;&#x3002;</p>
<pre><code class="lang-c"><span class="hljs-keyword">iostatus_t</span> io_create_device(
    <span class="hljs-keyword">driver_object_t</span> *driver,                <span class="hljs-comment">/* &#x9A71;&#x52A8;&#x6307;&#x9488; */</span>
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> device_extension_size,    <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x6269;&#x5C55;&#x5927;&#x5C0F; */</span>
    <span class="hljs-keyword">char</span> *device_name,                      <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x540D;&#x5B57; */</span>
    <span class="hljs-keyword">device_type_t</span> type,                     <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x7C7B;&#x578B; */</span>
    <span class="hljs-keyword">device_object_t</span> **device                <span class="hljs-comment">/* &#x521B;&#x5EFA;&#x5B8C;&#x6210;&#x540E;&#x7684;&#x8BBE;&#x5907;&#x6307;&#x9488; */</span>
);
</code></pre>
<p>&#x8C03;&#x7528;&#x5982;&#x679C;<code>device_extension_size</code>&#x4F20;&#x5165;0&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x4E0D;&#x4F1A;&#x4E3A;&#x8BBE;&#x5907;&#x5BF9;&#x8C61;&#x9884;&#x7559;&#x6269;&#x5C55;&#x533A;&#x57DF;&#xFF0C;&#x521B;&#x5EFA;&#x540E;&#x7684;<code>device_object.device_extension</code>&#x5C31;&#x662F;<code>NULL</code>&#xFF0C;&#x4E0D;&#x7136;&#xFF0C;&#x5C31;&#x662F;&#x6307;&#x5411;&#x4E86;&#x6269;&#x5C55;&#x533A;&#x7684;&#x5730;&#x5740;&#x3002;</p>
<p>&#x6CE8;&#x610F;<code>device</code>&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x53CC;&#x6307;&#x9488;&#xFF0C;&#x90A3;&#x4E48;&#xFF0C;&#x9700;&#x8981;&#x4F20;&#x5165;&#x4E00;&#x4E2A;&#x6307;&#x5411;&#x6307;&#x9488;&#x7684;&#x5730;&#x5740;&#xFF0C;&#x56E0;&#x6B64;&#x6709;<code>device_object_t *devobj;</code>&#x751F;&#x547D;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#xFF0C;&#x7136;&#x540E;&#x4F20;&#x8FDB;&#x53BB;&#x65F6;&#xFF0C;&#x4F7F;&#x7528;&#x7684;&#x662F;<code>&amp;devobj</code>&#xFF0C;&#x5982;&#x679C;&#x521B;&#x5EFA;&#x6210;&#x529F;&#xFF0C;<code>devobj</code>&#x5C31;&#x6307;&#x5411;&#x4E86;&#x521B;&#x5EFA;&#x7684;&#x8BBE;&#x5907;&#x7684;&#x5730;&#x5740;&#x3002;</p>
<p><code>devobj-&gt;flags</code>&#x662F;&#x8BBE;&#x5907;&#x7684;&#x6807;&#x5FD7;&#xFF0C;&#x8BE5;&#x6807;&#x5FD7;&#x652F;&#x6301;&#x7684;&#x503C;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-c"><span class="hljs-keyword">enum</span> _device_object_flags {
    DO_BUFFERED_IO              = (<span class="hljs-number">1</span> &lt;&lt; <span class="hljs-number">0</span>),     <span class="hljs-comment">/* &#x7F13;&#x51B2;&#x533A;IO */</span>
    DO_DIRECT_IO                = (<span class="hljs-number">1</span> &lt;&lt; <span class="hljs-number">1</span>),     <span class="hljs-comment">/* &#x76F4;&#x63A5;&#x5185;&#x5B58;IO */</span>
    DO_DISPENSE                 = (<span class="hljs-number">1</span> &lt;&lt; <span class="hljs-number">2</span>),     <span class="hljs-comment">/* &#x5206;&#x53D1;&#x4F4D; */</span>
};
</code></pre>
<p>&#x6211;&#x4EEC;&#x53EA;&#x662F;&#x4F7F;&#x5230;&#x4E86;<code>DO_BUFFERED_IO</code>&#x548C;<code>DO_DIRECT_IO</code>&#x3002;&#x4E0B;&#x9762;&#xFF0C;&#x8BE6;&#x7EC6;&#x89E3;&#x91CA;&#x4E00;&#x4E0B;&#x8FD9;&#x4E24;&#x4E2A;&#x6807;&#x5FD7;&#x7684;&#x610F;&#x601D;&#x3002;&#x4E0D;&#x8FC7;&#xFF0C;&#x5728;&#x8BA4;&#x8BC6;&#x5728;&#x8FD9;&#x4E4B;&#x524D;&#xFF0C;&#x6211;&#x4EEC;&#x8FD8;&#x9700;&#x8981;&#x8BA4;&#x8BC6;&#x4E00;&#x4E2A;&#x7ED3;&#x6784;&#x4F53;&#xFF0C;&#x90A3;&#x5C31;&#x662F;<code>io_request_t</code>&#x3002;</p>
<pre><code class="lang-c"><span class="hljs-comment">/* &#x8F93;&#x5165;&#x8F93;&#x51FA;&#x8BF7;&#x6C42; */</span>
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">struct</span> _io_request 
{
    <span class="hljs-keyword">list_t</span> <span class="hljs-built_in">list</span>;                        <span class="hljs-comment">/* &#x961F;&#x5217;&#x94FE;&#x8868; */</span>
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> flags;                 <span class="hljs-comment">/* &#x6807;&#x5FD7; */</span>
    <span class="hljs-keyword">struct</span> _mdl *mdl_address;           <span class="hljs-comment">/* &#x5185;&#x5B58;&#x63CF;&#x8FF0;&#x5217;&#x8868;&#x5730;&#x5740; */</span>
    <span class="hljs-keyword">void</span> *system_buffer;                <span class="hljs-comment">/* &#x7CFB;&#x7EDF;&#x7F13;&#x51B2;&#x533A; */</span>
    <span class="hljs-keyword">void</span> *user_buffer;                  <span class="hljs-comment">/* &#x7528;&#x6237;&#x7F13;&#x51B2;&#x533A; */</span>
    <span class="hljs-keyword">struct</span> _device_object *devobj;      <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x5BF9;&#x8C61; */</span>
    <span class="hljs-keyword">io_parame_t</span> parame;                 <span class="hljs-comment">/* &#x53C2;&#x6570; */</span>
    <span class="hljs-keyword">io_status_block_t</span> io_status;        <span class="hljs-comment">/* &#x72B6;&#x6001;&#x5757; */</span>

} <span class="hljs-keyword">io_request_t</span>;
</code></pre>
<p>&#x5F53;&#x6211;&#x4EEC;&#x6267;&#x884C;&#x6D3E;&#x9063;&#x51FD;&#x6570;&#x65F6;&#xFF0C;&#x5C31;&#x4F1A;&#x4F20;&#x5165;&#x8BBE;&#x5907;&#x548C;io&#x8BF7;&#x6C42;&#x3002;</p>
<pre><code class="lang-c"><span class="hljs-comment">/* &#x6D3E;&#x9063;&#x51FD;&#x6570;&#x5B9A;&#x4E49; */</span> 
<span class="hljs-function"><span class="hljs-keyword">typedef</span> <span class="hljs-title">iostatus_t</span> <span class="hljs-params">(*driver_dispatch_t)</span><span class="hljs-params">(device_object_t *device, io_request_t *ioreq)</span></span>;
</code></pre>
<p>&#x6B64;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x8FD8;&#x9700;&#x8981;&#x5173;&#x6CE8;&#x4E00;&#x4E2A;&#x7ED3;&#x6784;&#x4F53;&#xFF0C;<code>io_parame_t</code>&#xFF0C;&#x5B9A;&#x4E49;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-c"><span class="hljs-keyword">typedef</span> <span class="hljs-keyword">struct</span> _io_parame {
    <span class="hljs-keyword">union</span> 
    {
        <span class="hljs-keyword">struct</span> {
            <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> flags;
            <span class="hljs-keyword">char</span> *devname;
        } open;
        <span class="hljs-keyword">struct</span> {
            <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> length;
            <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> offset;
        } read;
        <span class="hljs-keyword">struct</span> {
            <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> length;
            <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> offset;
        } write;
        <span class="hljs-keyword">struct</span> {
            <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> code;
            <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> arg;
        } devctl;
        <span class="hljs-keyword">struct</span> {
            <span class="hljs-keyword">int</span> flags;
            <span class="hljs-keyword">size_t</span> length;
        } mmap;

    };
} <span class="hljs-keyword">io_parame_t</span>;
</code></pre>
<p>&#x5B83;&#x7684;&#x5185;&#x5BB9;&#x662F;&#x4E00;&#x4E2A;&#x8054;&#x5408;&#x4F53;&#xFF0C;&#x5728;&#x8054;&#x5408;&#x91CC;&#x9762;&#x6709;<code>open,read,write,devctl,mmap</code>&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x5F53;&#x6267;&#x884C;&#x8FD9;&#x4E9B;&#x5BF9;&#x5E94;&#x6D3E;&#x9063;&#x51FD;&#x6570;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5BF9;&#x5E94;&#x7684;&#x53C2;&#x6570;&#x83B7;&#x53D6;&#x5230;&#x53C2;&#x6570;&#x503C;&#x3002;&#x6BD4;&#x5982;&#xFF0C;&#x5728;<code>null</code>&#x9A71;&#x52A8;&#x4E2D;&#xFF0C;&#x8C03;&#x7528;<code>zero_read</code>&#x6D3E;&#x9063;&#x51FD;&#x6570;&#x7684;&#x65F6;&#x5019;&#xFF0C;<code>ioreq</code>&#x5BF9;&#x5E94;&#x7684;<code>parame</code>&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>ioreq-&gt;parame.read</code>&#x6765;&#x53D6;&#x503C;&#xFF0C;&#x6BD4;&#x5982;&#x8FD9;&#x91CC;&#x901A;&#x8FC7;<code>ioreq-&gt;parame.read.length</code>&#x83B7;&#x53D6;&#x4E86;&#x8981;&#x8BFB;&#x53D6;&#x6570;&#x636E;&#x7684;&#x957F;&#x5EA6;&#x3002;&#x5982;&#x679C;&#x662F;<code>xxx_write</code>&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x662F;&#x901A;&#x8FC7;<code>ioreq-&gt;parame.write.length</code>&#x6765;&#x83B7;&#x53D6;&#x8981;&#x5199;&#x5165;&#x6570;&#x636E;&#x7684;&#x957F;&#x5EA6;&#x3002;</p>
<p>&#x90A3;&#x4E48;<code>devobj-&gt;flags</code>&#x548C;&#x8FD9;&#x4E2A;<code>io_request_t</code>&#x6709;&#x4EC0;&#x4E48;&#x5173;&#x7CFB;&#x5462;&#xFF1F;&#x63A5;&#x4E0B;&#x6765;&#x5C31;&#x53EF;&#x4EE5;&#x8FDB;&#x884C;&#x63CF;&#x8FF0;&#x4E86;&#x3002;</p>
<p>&#x5F53;&#x6211;&#x4EEC;&#x8FDB;&#x884C;read&#x6216;&#x8005;write&#x65F6;&#xFF0C;&#x5C31;&#x4F1A;&#x6709;&#x8BFB;&#x5199;&#x7F13;&#x51B2;&#x533A;&#xFF0C;&#x800C;<code>devobj-&gt;flags</code>&#x5C31;&#x8BB0;&#x5F55;&#x7740;&#x8FD9;&#x4E2A;&#x7F13;&#x51B2;&#x533A;&#x600E;&#x4E48;&#x4F20;&#x9012;&#x3002;</p>
<table>
<thead>
<tr>
<th>devobj-&gt;flags</th>
<th>&#x63CF;&#x8FF0;</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>&#x8FD9;&#x662F;&#x91C7;&#x7528;DO_NEITHER_IO&#x6A21;&#x5F0F;&#xFF0C;&#x610F;&#x601D;&#x662F;&#x65E2;&#x4E0D;&#x662F;DO_BUFFERED_IO&#x4E5F;&#x4E0D;&#x662F;DO_DIRECT_IO&#x3002;&#x5728;&#x8FD9;&#x4E2A;&#x6A21;&#x5F0F;&#x4E0B;&#x9762;&#xFF0C;&#x5F53;&#x8FDB;&#x884C;&#x8BFB;&#x5199;&#x65F6;&#xFF0C;&#x4F20;&#x5165;&#x7684;&#x7F13;&#x51B2;&#x533A;&#x4F7F;&#x7528;ioreq-&gt;user_buffer&#xFF0C;&#x8868;&#x793A;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x7528;&#x6237;&#x7684;&#x7F13;&#x51B2;&#x533A;&#x5730;&#x5740;&#xFF0C;&#x800C;&#x4E0D;&#x505A;&#x989D;&#x5916;&#x5904;&#x7406;&#x3002;</td>
</tr>
<tr>
<td>DO_BUFFERED_IO</td>
<td>&#x8FD9;&#x662F;&#x91C7;&#x7528;&#x7F13;&#x51B2;&#x533A;IO&#x6A21;&#x5F0F;&#xFF0C;&#x610F;&#x601D;&#x662F;&#xFF0C;&#x8FDB;&#x884C;&#x8BFB;&#x5199;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F1A;&#x505A;&#x4E00;&#x4E2A;buffer&#x62F7;&#x8D1D;&#x3002;&#x5F53;&#x8FDB;&#x884C;write&#x5199;&#x5165;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F20;&#x8FC7;&#x6765;&#x7684;&#x7F13;&#x51B2;&#x533A;&#x662F;&#x5728;&#x5185;&#x6838;&#x4E2D;&#x5206;&#x914D;&#x7684;&#x4E00;&#x4E2A;&#x7F13;&#x51B2;&#x533A;&#xFF0C;&#x7136;&#x540E;&#x8FD9;&#x4E2A;&#x7F13;&#x51B2;&#x533A;&#x4F1A;&#x5148;&#x5C06;&#x7528;&#x6237;&#x7684;buffer&#x5185;&#x5BB9;&#x62F7;&#x8D1D;&#x8FDB;&#x53BB;&#xFF0C;&#x7136;&#x540E;&#x5C06;&#x8FD9;&#x4E2A;&#x5185;&#x6838;&#x7F13;&#x51B2;&#x533A;&#x4F20;&#x9012;&#x8FC7;&#x6765;&#xFF0C;&#x6B64;&#x65F6;&#x4F7F;&#x7528;&#x7684;&#x662F;ioreq-&gt;system_buffer&#x3002;&#x8FD9;&#x4E48;&#x505A;&#x7684;&#x539F;&#x56E0;&#x662F;&#x4E3A;&#x4E86;&#x6EE1;&#x8DB3;&#x6709;&#x4E2D;&#x65AD;&#x4EA7;&#x751F;&#x7684;&#x9A71;&#x52A8;&#xFF0C;&#x4EA7;&#x751F;&#x540E;&#x8FDB;&#x884C;&#x6570;&#x636E;&#x8BFB;&#x5199;&#x62F7;&#x8D1D;&#x3002;&#x6BD4;&#x5982;&#x73B0;&#x5728;&#x662F;&#x5728;dd&#xFF0C;&#x8FD9;&#x4E2A;&#x7A0B;&#x5E8F;&#x6267;&#x884C;&#x4E86;write&#x7CFB;&#x7EDF;&#x8C03;&#x7528;&#xFF0C;&#x5F80;&#x67D0;&#x4E2A;&#x78C1;&#x76D8;&#x5199;&#x5165;&#x6570;&#x636E;&#xFF0C;&#x5199;&#x5165;&#x7B2C;&#x4E00;&#x4E2A;&#x6247;&#x533A;&#x540E;&#x4EA7;&#x751F;&#x4E86;&#x4E2D;&#x65AD;&#xFF0C;&#x7136;&#x540E;&#x518D;&#x6B21;&#x5199;&#x5165;&#x7B2C;&#x4E8C;&#x4E2A;&#x6247;&#x533A;&#xFF0C;&#x5982;&#x679C;&#x4EA7;&#x751F;&#x4E2D;&#x65AD;&#x65F6;&#x5F53;&#x524D;&#x8C03;&#x5EA6;&#x7684;&#x7A0B;&#x5E8F;&#x65F6;init&#x7A0B;&#x5E8F;&#xFF0C;&#x90A3;&#x4E48;&#x5982;&#x679C;&#x76F4;&#x63A5;&#x4ECE;&#x7528;&#x6237;&#x7684;&#x5730;&#x5740;&#x8BFB;&#x53D6;&#x6570;&#x636E;&#xFF0C;&#x6B64;&#x65F6;&#x662F;&#x6CA1;&#x6709;dd&#x6570;&#x636E;&#x7684;&#x5730;&#x5740;&#x7684;&#xFF0C;&#x90A3;&#x4E48;&#x6B64;&#x65F6;&#x8FDB;&#x884C;&#x6570;&#x636E;&#x8BFB;&#x53D6;&#x5C31;&#x4F1A;&#x4EA7;&#x751F;&#x9519;&#x8BEF;&#x3002;&#x89E3;&#x51B3;&#x65B9;&#x6CD5;&#x5C31;&#x662F;&#xFF0C;&#x5728;&#x5185;&#x6838;&#x5206;&#x914D;&#x4E00;&#x4E2A;&#x7F13;&#x51B2;&#x533A;&#xFF0C;&#x56E0;&#x4E3A;&#x5185;&#x6838;&#x7F13;&#x51B2;&#x533A;&#x662F;&#x6240;&#x6709;&#x8FDB;&#x7A0B;&#x5171;&#x4EAB;&#x7684;&#xFF0C;&#x4E8E;&#x662F;&#xFF0C;&#x5C31;&#x7B97;&#x662F;&#x4EA7;&#x751F;&#x4E2D;&#x65AD;&#x4E86;&#xFF0C;&#x8981;&#x6C42;&#x5199;&#x5165;&#x4E0B;&#x4E00;&#x4E2A;&#x6247;&#x533A;&#xFF0C;&#x90A3;&#x4E48;&#x6570;&#x636E;&#x662F;&#x5728;&#x5185;&#x6838;&#x4E2D;&#xFF0C;&#x6B64;&#x65F6;&#x4E5F;&#x662F;&#x53EF;&#x4EE5;&#x6B63;&#x5E38;&#x83B7;&#x53D6;&#x6570;&#x636E;&#x7684;&#x3002;</td>
</tr>
<tr>
<td>DO_DIRECT_IO</td>
<td>&#x8FD9;&#x662F;&#x91C7;&#x53D6;&#x76F4;&#x63A5;IO&#x6A21;&#x5F0F;&#xFF0C;&#x5728;&#x8FD9;&#x4E2A;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;&#x662F;&#x5BF9;DO_BUFFERED_IO&#x7684;&#x4F18;&#x5316;&#x3002;&#x56E0;&#x4E3A;DO_BUFFERED_IO&#x9700;&#x8981;&#x5206;&#x914D;&#x4E00;&#x4E2A;&#x5185;&#x6838;&#x7F13;&#x51B2;&#x533A;&#xFF0C;&#x5E76;&#x505A;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x590D;&#x5236;&#xFF0C;&#x56E0;&#x6B64;&#x4F1A;&#x6BD4;&#x8F83;&#x6D88;&#x8017;&#x6027;&#x80FD;&#x3002;&#x4E8E;&#x662F;&#x91C7;&#x7528;&#x76F4;&#x63A5;IO&#x6A21;&#x5F0F;&#xFF0C;&#x5C06;&#x7528;&#x6237;&#x7F13;&#x51B2;&#x533A;&#x7684;&#x5730;&#x5740;&#x76F4;&#x63A5;&#x6620;&#x5C04;&#x5230;&#x5185;&#x6838;&#x7684;&#x865A;&#x62DF;&#x5730;&#x5740;&#x4E2D;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x901A;&#x8FC7;&#x8FD9;&#x4E2A;&#x5730;&#x5740;&#x6765;&#x8BBF;&#x95EE;&#x7528;&#x6237;&#x7684;&#x6570;&#x636E;&#x4E86;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x590D;&#x5236;&#x6570;&#x636E;&#xFF0C;&#x5E76;&#x4E14;&#x5728;&#x6267;&#x884C;&#x5B8C;&#x540E;&#xFF0C;&#x4F1A;&#x89E3;&#x9664;&#x6620;&#x5C04;&#x3002;&#x4F46;&#x662F;&#x8FD9;&#x79CD;&#x6A21;&#x5F0F;&#x6620;&#x5C04;&#x548C;&#x89E3;&#x9664;&#x6620;&#x5C04;&#x4E5F;&#x9700;&#x8981;&#x82B1;&#x8D39;&#x4E00;&#x5B9A;&#x65F6;&#x95F4;&#xFF0C;&#x9002;&#x5408;&#x8BFB;&#x5199;&#x6570;&#x636E;&#x6BD4;&#x8F83;&#x5927;&#x7684;&#x65F6;&#x5019;&#x4F7F;&#x7528;&#x3002;&#x6570;&#x636E;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;ioreq-&gt;mdl_address&#x83B7;&#x53D6;&#xFF0C;&#x4E0D;&#x8FC7;&#x6CE8;&#x610F;&#xFF0C;&#x8FD9;&#x4E2A;&#x5730;&#x5740;&#x662F;&#x4E00;&#x4E2A;&#x7ED3;&#x6784;&#x4F53;&#xFF0C;&#x8FD8;&#x9700;&#x8981;&#x8FDB;&#x4E00;&#x6B65;&#x4ECE;&#x91CC;&#x9762;&#x83B7;&#x53D6;&#x5177;&#x4F53;&#x5730;&#x5740;&#x3002;</td>
</tr>
</tbody>
</table>
<p>&#x5728;&#x5B9E;&#x9645;&#x7684;&#x4F7F;&#x7528;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x5E38;&#x7528;&#x7684;&#x662F;0&#x548C;<code>DO_BUFFERED_IO</code>&#x6A21;&#x5F0F;&#x3002;&#x5728;null&#x9A71;&#x52A8;&#x4E2D;&#xFF0C;<code>devobj-&gt;flags</code>&#x7684;&#x503C;&#x662F;0&#xFF0C;&#x8868;&#x793A;<code>DO_NEITHER_IO</code>&#x6A21;&#x5F0F;&#x3002;</p>
<p>&#x5728;<code>zero_read</code>&#x51FD;&#x6570;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x6709;&#x4E00;&#x4E2A;&#x8FD4;&#x56DE;&#x503C;&#xFF0C;&#x7528;&#x7684;&#x662F;<code>iostatus_t</code>&#x6765;&#x8868;&#x793A;&#x64CD;&#x4F5C;&#x6267;&#x884C;&#x7684;&#x72B6;&#x6001;&#x3002;</p>
<pre><code class="lang-c"><span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> IO_SUCCESS             0           <span class="hljs-comment">/* &#x6210;&#x529F; */</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> IO_FAILED              (1 &lt;&lt; 0)    <span class="hljs-comment">/* &#x5931;&#x8D25; */</span></span>
</code></pre>
<p>&#x901A;&#x5E38;&#x6211;&#x4EEC;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;IO&#x5B8F;&#x8868;&#x793A;&#x6210;&#x529F;&#x548C;&#x5931;&#x8D25;&#x7684;&#x503C;&#x3002;</p>
<p>&#x9664;&#x6B64;&#x4E4B;&#x5916;&#xFF0C;&#x8FD8;&#x9700;&#x8981;&#x5728;&#x6BCF;&#x4E2A;&#x51FD;&#x6570;&#x4E2D;&#x8C03;&#x7528;&#x5B8C;&#x6210;&#x8BF7;&#x6C42;&#x51FD;&#x6570;<code>io_complete_request</code>&#x6765;&#x8868;&#x793A;&#x5DF2;&#x7ECF;&#x5B8C;&#x6210;&#x4E86;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x7684;&#x6267;&#x884C;&#x3002;&#x9664;&#x6B64;&#x4E4B;&#x5916;&#xFF0C;&#x8FD8;&#x9700;&#x8981;&#x586B;&#x5199;<code>ioreq</code>&#x7684;<code>io_status</code>&#xFF0C;&#x8868;&#x793A;&#x672C;&#x6B21;&#x6267;&#x884C;&#x7684;&#x72B6;&#x51B5;&#x3002;<code>ioreq-&gt;io_status.status</code>&#x5219;&#x662F;&#x6267;&#x884C;&#x72B6;&#x6001;&#xFF0C;&#x548C;&#x8FD4;&#x56DE;&#x503C;&#x4FDD;&#x6301;&#x4E00;&#x81F4;&#xFF0C;<code>ioreq-&gt;io_status.infomation</code>&#x4FDD;&#x5B58;&#x6267;&#x884C;&#x540E;&#x7684;&#x4FE1;&#x606F;&#xFF0C;&#x6BD4;&#x5982;&#x5728;<code>zero_read</code>&#x4E2D;&#xFF0C;&#x8FD9;&#x4E2A;&#x4FE1;&#x606F;&#x7684;&#x503C;&#x5C31;&#x662F;&#x6210;&#x529F;&#x8BFB;&#x53D6;&#x7684;&#x6570;&#x636E;&#x91CF;&#x3002;</p>
<p>&#x73B0;&#x5728;&#x5DEE;&#x4E0D;&#x591A;&#x6574;&#x4E2A;&#x9A71;&#x52A8;&#x7684;&#x5185;&#x5BB9;&#x90FD;&#x5DF2;&#x7ECF;&#x8BB2;&#x5B8C;&#x4E86;&#x3002;</p>
<p>&#x6700;&#x540E;&#x518D;&#x8BB2;&#x4E00;&#x4E0B;<code>zero_exit</code>&#xFF0C;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x505A;&#x7684;&#x5C31;&#x662F;&#x9000;&#x51FA;&#x9A71;&#x52A8;&#x7684;&#x4E8B;&#x60C5;&#x3002;&#x56E0;&#x4E3A;&#x6240;&#x6709;&#x8BBE;&#x5907;&#x662F;&#x901A;&#x8FC7;&#x94FE;&#x8868;&#x7684;&#x5F62;&#x5F0F;&#x6302;&#x5728;driver&#x4E0B;&#x9762;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x9700;&#x8981;&#x901A;&#x8FC7;&#x4E00;&#x4E2A;&#x94FE;&#x8868;&#x5FAA;&#x73AF;&#x6765;&#x83B7;&#x53D6;&#x6240;&#x6709;&#x8BBE;&#x5907;&#xFF0C;&#x5E76;&#x901A;&#x8FC7;<code>io_delete_device</code>&#x51FD;&#x6570;&#x5C06;&#x8BBE;&#x5907;&#x4ECE;&#x9A71;&#x52A8;&#x4E2D;&#x5220;&#x9664;&#x3002;</p>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">io_delete_device</span><span class="hljs-params">(
    device_object_t *device                 <span class="hljs-comment">/* &#x8981;&#x8BBE;&#x5907;&#x7684;&#x5BF9;&#x8C61; */</span>
)</span></span>;
</code></pre>
<p>&#x6700;&#x540E;&#xFF0C;&#x8FD8;&#x9700;&#x8981;&#x5220;&#x9664;&#x9A71;&#x52A8;&#x7684;&#x540D;&#x5B57;&#xFF0C;&#x901A;&#x8FC7;<code>string_del</code>&#x6765;&#x5B9E;&#x73B0;&#x3002;</p>
<h3 id="&#x66F4;&#x591A;&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x5206;&#x6790;">&#x66F4;&#x591A;&#x9A71;&#x52A8;&#x7A0B;&#x5E8F;&#x5206;&#x6790;</h3>
<p><a href="ahci.html">&#x300A;ahci&#x78C1;&#x76D8;&#x9A71;&#x52A8;&#x5206;&#x6790;&#x300B;</a></p>
<p><a href="keyboard.html">&#x300A;keyboard&#x952E;&#x76D8;&#x9A71;&#x52A8;&#x5206;&#x6790;&#x300B;</a></p>
<h2 id="&#x4E2D;&#x65AD;&#x7BA1;&#x7406;">&#x4E2D;&#x65AD;&#x7BA1;&#x7406;</h2>
<p>&#x5728;xbook2&#x7684;&#x4E2D;&#x65AD;&#x7BA1;&#x7406;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x4E86;&#x89E3;&#x5176;&#x63A5;&#x53E3;&#x7684;&#x4F7F;&#x7528;&#x5373;&#x53EF;&#xFF0C;&#x5982;&#x679C;&#x60F3;&#x8981;&#x4E86;&#x89E3;&#x5176;&#x5B9E;&#x73B0;&#x539F;&#x7406;&#xFF0C;&#x53EF;&#x4EE5;&#x81EA;&#x884C;&#x7814;&#x7A76;&#x3002;</p>
<h3 id="&#x4E2D;&#x65AD;&#x63A5;&#x53E3;">&#x4E2D;&#x65AD;&#x63A5;&#x53E3;</h3>
<p>&#x4F60;&#x9700;&#x8981;&#x5F15;&#x5165;&#x7684;&#x5934;&#x6587;&#x4EF6;&#x662F;<code>&lt;xbook/hardirq.h&gt;</code></p>
<p>&#x4E2D;&#x65AD;&#x63A5;&#x53E3;&#x5206;&#x4E3A;&#x6CE8;&#x518C;&#x4E2D;&#x65AD;&#xFF0C;&#x6CE8;&#x9500;&#x4E2D;&#x65AD;&#xFF0C;&#x4EE5;&#x53CA;&#x6355;&#x6349;&#x4E2D;&#x65AD;&#x3002;</p>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">irq_register</span><span class="hljs-params">(irqno_t irq,    <span class="hljs-comment">/* &#x4E2D;&#x65AD;irq&#x53F7; */</span>
    irq_handler_t handler,         <span class="hljs-comment">/* &#x4E2D;&#x65AD;&#x5904;&#x7406;&#x51FD;&#x6570; */</span>
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> flags,        <span class="hljs-comment">/* &#x4E2D;&#x65AD;&#x6807;&#x5FD7; */</span>
    <span class="hljs-keyword">char</span> *irqname,                <span class="hljs-comment">/* &#x4E2D;&#x65AD;&#x540D;&#x5B57; */</span>
    <span class="hljs-keyword">char</span> *devname,                <span class="hljs-comment">/* &#x8BBE;&#x5907;&#x540D;&#x5B57; */</span>
    <span class="hljs-keyword">void</span> *data)</span></span>;                <span class="hljs-comment">/* &#x4E2D;&#x65AD;&#x79C1;&#x6709;&#x6570;&#x636E; */</span>
</code></pre>
<p>&#x5F53;&#x9700;&#x8981;&#x6CE8;&#x518C;&#x4E00;&#x4E2A;&#x4E2D;&#x65AD;&#x65F6;&#xFF0C;&#x9700;&#x8981;&#x4F20;&#x5165;&#x4E2D;&#x65AD;&#x53F7;<code>irq</code>&#x6765;&#x8868;&#x660E;&#x662F;&#x54EA;&#x4E2A;&#x4E2D;&#x65AD;&#x3002;&#x4F20;&#x5165;<code>handler</code>&#x6765;&#x6267;&#x884C;&#x4E2D;&#x65AD;&#x5904;&#x7406;&#xFF0C;&#x8FD9;&#x4E2A;&#x662F;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x6307;&#x9488;&#x3002;</p>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">typedef</span> <span class="hljs-title">int</span> <span class="hljs-params">(*irq_handler_t)</span><span class="hljs-params">(irqno_t, <span class="hljs-keyword">void</span> *)</span></span>;
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> IRQ_HANDLED        0</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> IRQ_NEXTONE        -1</span>
</code></pre>
<p>&#x8FD9;&#x662F;&#x4E2D;&#x65AD;&#x5904;&#x7406;&#x51FD;&#x6570;&#x7684;&#x6307;&#x9488;&#x7C7B;&#x578B;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5B9A;&#x4E49;&#x5BF9;&#x5E94;&#x7684;&#x4E2D;&#x65AD;&#x5904;&#x7406;&#x51FD;&#x6570;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">xxx_handler</span><span class="hljs-params">(irqno_t no, <span class="hljs-keyword">void</span> *data)</span>
</span>{
    xxx
    <span class="hljs-keyword">return</span> IRQ_HANDLED;    <span class="hljs-comment">/* &#x5DF2;&#x7ECF;&#x5904;&#x7406;&#x5219;&#x9700;&#x8981;&#x8FD4;&#x56DE;HANDLED */</span>
}
</code></pre>
<p><code>IRQ_HANDLED</code>&#x8868;&#x793A;&#x4E2D;&#x65AD;&#x88AB;&#x6210;&#x529F;&#x5904;&#x7406;&#xFF0C;&#x800C;<code>IRQ_NEXTONE</code>&#x8868;&#x793A;&#x672C;&#x9A71;&#x52A8;&#x4E0D;&#x8BC6;&#x522B;&#x8FD9;&#x4E2A;&#x4E2D;&#x65AD;&#xFF0C;&#x5E0C;&#x671B;&#x4E0B;&#x4E00;&#x4E2A;&#x9A71;&#x52A8;&#x80FD;&#x591F;&#x5904;&#x7406;&#x8FD9;&#x4E2A;&#x4E2D;&#x65AD;&#xFF0C;&#x8FD9;&#x662F;&#x5728;&#x5171;&#x4EAB;&#x4E2D;&#x65AD;&#x4E2D;&#x4F7F;&#x7528;&#x7684;&#x3002;</p>
<p>flags&#x6807;&#x5FD7;&#xFF0C;&#x53EF;&#x4EE5;&#x5BF9;&#x8FD9;&#x4E2A;&#x4E2D;&#x65AD;&#x8FDB;&#x884C;&#x4E00;&#x5B9A;&#x7684;&#x8BBE;&#x7F6E;&#xFF0C;&#x5176;&#x503C;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-c"><span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> IRQF_DISABLED       0x01</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> IRQF_SHARED         0x02</span>
</code></pre>
<p>&#x5F53;&#x6709;<code>IRQF_DISABLED</code>&#x6807;&#x5FD7;&#x65F6;&#xFF0C;&#x8868;&#x793A;&#x5904;&#x7406;&#x4E2D;&#x65AD;&#x51FD;&#x6570;&#x8FC7;&#x7A0B;&#x4E2D;&#x4F1A;&#x5173;&#x95ED;&#x4E2D;&#x65AD;&#xFF0C;&#x5F53;&#x6709;<code>IRQF_SHARED</code>&#x65F6;&#xFF0C;&#x8868;&#x793A;&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x5171;&#x4EAB;&#x4E2D;&#x65AD;&#xFF0C;&#x90A3;&#x4E48;&#x591A;&#x4E2A;&#x9A71;&#x52A8;&#x90FD;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x4E2D;&#x65AD;<code>irq</code>&#x3002;&#x5982;&#x679C;&#x662F;<code>IRQF_SHARED</code>&#xFF0C;&#x90A3;&#x4E48;<code>data</code>&#x4E00;&#x5B9A;&#x4E0D;&#x80FD;&#x4E3A;<code>NULL</code>&#x3002;</p>
<p>&#x6CE8;&#x518C;&#x6210;&#x529F;&#x540E;&#xFF0C;&#x8FD4;&#x56DE;0&#xFF0C;&#x5931;&#x8D25;&#x8FD4;&#x56DE;-1&#x3002;</p>
<p>&#x5F53;&#x9700;&#x8981;&#x6CE8;&#x9500;&#x4E00;&#x4E2A;&#x4E2D;&#x65AD;&#x65F6;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>irq_unregister</code>&#x6765;&#x6CE8;&#x9500;&#x4E2D;&#x65AD;&#x3002;</p>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">irq_unregister</span><span class="hljs-params">(irqno_t irq, <span class="hljs-keyword">void</span> *data)</span></span>;
</code></pre>
<p><code>irq</code>&#x662F;&#x4E2D;&#x65AD;&#x53F7;&#xFF0C;<code>data</code>&#x662F;&#x6CE8;&#x518C;&#x65F6;&#x4F20;&#x5165;&#x7684;&#x6570;&#x636E;&#x3002;&#x56E0;&#x4E3A;&#x53EF;&#x80FD;&#x662F;&#x5171;&#x4EAB;&#x4E2D;&#x65AD;&#xFF0C;&#x6240;&#x4EE5;<code>data</code>&#x7528;&#x6765;&#x8BC6;&#x522B;&#x4E0D;&#x540C;&#x7684;&#x9A71;&#x52A8;&#x3002;</p>
<h3 id="ps2&#x952E;&#x76D8;&#x4E2D;&#x65AD;&#x6848;&#x4F8B;">PS/2&#x952E;&#x76D8;&#x4E2D;&#x65AD;&#x6848;&#x4F8B;</h3>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">static</span> <span class="hljs-keyword">int</span> <span class="hljs-title">keyboard_handler</span><span class="hljs-params">(irqno_t irq, <span class="hljs-keyword">void</span> *data)</span>
</span>{
    <span class="hljs-keyword">device_extension_t</span> *ext = (<span class="hljs-keyword">device_extension_t</span> *) data;
    ...xxx...
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
irq_register(devext-&gt;irq, keyboard_handler, IRQF_DISABLED, <span class="hljs-string">&quot;IRQ1&quot;</span>, DRV_NAME, (<span class="hljs-keyword">void</span> *) devext);
</code></pre>
<p>&#x5728;&#x8FD9;&#x4E2A;&#x952E;&#x76D8;&#x9A71;&#x52A8;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;<code>flags</code>&#x662F;<code>IRQF_DISABLED</code>&#xFF0C;&#x8868;&#x793A;&#x5728;&#x952E;&#x76D8;&#x4E2D;&#x65AD;&#x51FD;&#x6570;&#x5904;&#x7406;&#x671F;&#x95F4;&#x9700;&#x8981;&#x5173;&#x95ED;&#x4E2D;&#x65AD;&#xFF0C;<code>data</code>&#x662F;<code>devext</code>&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x53EF;&#x4EE5;&#x5728;<code>keyboard_handler</code>&#x4E2D;&#x901A;&#x8FC7;<code>data</code>&#x4F20;&#x5165;&#xFF0C;&#x4ECE;&#x800C;&#x53EF;&#x4EE5;&#x89E3;&#x6790;&#x51FA;&#x5BF9;&#x5E94;&#x7684;&#x63A5;&#x53E3;&#x4F53;&#xFF0C;&#x6765;&#x6EE1;&#x8DB3;&#x6211;&#x4EEC;&#x7684;&#x4F7F;&#x7528;&#x3002;</p>
<h3 id="ahci&#x78C1;&#x76D8;&#x9A71;&#x52A8;&#x4E2D;&#x65AD;&#x6848;&#x4F8B;">AHCI&#x78C1;&#x76D8;&#x9A71;&#x52A8;&#x4E2D;&#x65AD;&#x6848;&#x4F8B;</h3>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">static</span> <span class="hljs-keyword">int</span> <span class="hljs-title">ahci_handler</span><span class="hljs-params">(irqno_t irq, <span class="hljs-keyword">void</span> *data)</span>
</span>{
    <span class="hljs-keyword">int</span> intrhandled = IRQ_NEXTONE;
    <span class="hljs-keyword">int</span> i;
    <span class="hljs-keyword">for</span>(i=<span class="hljs-number">0</span>;i&lt;<span class="hljs-number">32</span>;i++) {
        <span class="hljs-keyword">if</span>(hba_mem-&gt;interrupt_status &amp; (<span class="hljs-number">1</span> &lt;&lt; i)) {
            dbgprint(<span class="hljs-string">&quot;ahci: interrupt %d occur!\n&quot;</span>, i);
            hba_mem-&gt;ports[i].interrupt_status = ~<span class="hljs-number">0</span>;
            hba_mem-&gt;interrupt_status = (<span class="hljs-number">1</span> &lt;&lt; i);
            ahci_flush_commands((<span class="hljs-keyword">struct</span> hba_port *)&amp;hba_mem-&gt;ports[i]);
            intrhandled = IRQ_HANDLED;
        }
    }
    <span class="hljs-keyword">return</span> intrhandled;
}

irq_register(ahci_int, ahci_handler, IRQF_SHARED, <span class="hljs-string">&quot;ahci&quot;</span>, <span class="hljs-string">&quot;ahci driver&quot;</span>, (<span class="hljs-keyword">void</span> *)driver);
</code></pre>
<p>&#x5728;&#x8FD9;&#x4E2A;&#x9A71;&#x52A8;&#x6848;&#x4F8B;&#x4E2D;&#xFF0C;<code>flags</code>&#x662F;<code>IRQF_SHARED</code>&#xFF0C;&#x8868;&#x793A;&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x5171;&#x4EAB;&#x4E2D;&#x65AD;&#xFF0C;<code>data</code>&#x4E3A;<code>driver</code>&#x9A71;&#x52A8;&#x672C;&#x8EAB;&#x3002;</p>
<p>&#x5728;&#x4E2D;&#x65AD;&#x5904;&#x7406;&#x51FD;&#x6570;&#x4E2D;&#x867D;&#x7136;&#x6CA1;&#x6709;&#x7528;&#x5230;<code>data</code>&#x8FD9;&#x4E2A;&#x53D8;&#x91CF;&#xFF0C;&#x4F46;&#x662F;&#x5FC5;&#x987B;&#x4F20;&#x5165;&#x4E00;&#x4E2A;&#x5730;&#x5740;&#xFF0C;&#x6765;&#x8868;&#x660E;&#x5B83;&#x4E0D;&#x540C;&#x4E8E;&#x5176;&#x5B83;&#x9A71;&#x52A8;&#xFF0C;&#x8FD9;&#x662F;&#x5171;&#x4EAB;&#x4E2D;&#x65AD;&#x5FC5;&#x987B;&#x7684;&#x3002;</p>
<p>&#x5728;<code>ahci_handler</code>&#x4E2D;&#xFF0C;&#x5982;&#x679C;&#x4E2D;&#x65AD;&#x88AB;&#x5904;&#x7406;&#x4E86;&#xFF0C;&#x5C31;&#x8FD4;&#x56DE;<code>IRQ_HANDLED</code>&#xFF0C;&#x6CA1;&#x6709;&#x88AB;&#x5904;&#x7406;&#x5C31;&#x8FD4;&#x56DE;<code>IRQ_NEXTONE</code>&#xFF0C;&#x8868;&#x793A;&#x9700;&#x8981;&#x5176;&#x5B83;&#x9A71;&#x52A8;&#x5904;&#x7406;&#x4E2D;&#x65AD;&#x3002;</p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; BookOS-developers 2021 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2021-06-16
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../mm/mm.html" class="navigation navigation-prev " aria-label="Previous page: 内存管理">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="ahci.html" class="navigation navigation-next " aria-label="Next page: AHCI磁盘驱动分析">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"设备管理","level":"1.1.3.5","depth":3,"next":{"title":"AHCI磁盘驱动分析","level":"1.1.3.5.1","depth":4,"path":"programing-manual/device/ahci.md","ref":"programing-manual/device/ahci.md","articles":[]},"previous":{"title":"内存管理","level":"1.1.3.4","depth":3,"path":"programing-manual/mm/mm.md","ref":"programing-manual/mm/mm.md","articles":[]},"dir":"ltr"},"config":{"plugins":["tbfed-pagefooter","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy BookOS-developers 2021","modify_label":"修订时间：","modify_format":"YYYY-MM-DD"},"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"jason hu","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"book for xbook2","language":"zh-hans","links":{"sidebar":{"bookos":"https://book-os.org"}},"gitbook":"3.2.3","description":"document for xbook2 kernel"},"file":{"path":"programing-manual/device/device.md","mtime":"2021-06-16T14:03:55.636Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-06-16T14:18:02.822Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

